Note Card Loop Example - Dedric Mauriac
February 12, 2010 · 157 views · 0 comments
Nearby In Time
Socrates Cafe - Dedric Mauriac
February 11, 2010
Macramakin' with Ellen - Dedric Mauriac
February 11, 2010
Tribute to RHPS - Dedric Mauriac
February 12, 2010
The Unfortunate Cookie - Dedric Mauriac
February 12, 2010
Note Card Loop Example - Dedric Mauriac
February 12, 2010
Blogging through Snapzilla - Dedric Mauriac
February 13, 2010
More autopost testing - Dedric Mauriac
February 13, 2010
My freebies listed with NCI - Dedric Mauriac
February 13, 2010
Batteries and the Rental Model - Dedric Mauriac
February 14, 2010
About
I was helping someone out with a simple request. He wanted a prim to change it's hover text to display messages from a note card. Once you reach the end of the note card, it needed to start from the beginning again. It took about 10 minutes, but i came up with a pretty strait forward example of how it can be done.integer noteCardLine;
integer noteCardCount;
string noteCardName;
key noteCardCountRequestId;
key noteCardLineRequestId;
init()
{
// reset to read first line
noteCardLine = 0;
// find the note card name
noteCardName = llGetInventoryName(INVENTORY_NOTECARD, 0);
// if note card is missing
if(noteCardName == "")
{
// notify owner
llOwnerSay("I don't have a note card to read!");
}
// count number of lines in note card
noteCardCountRequestId = llGetNumberOfNotecardLines(noteCardName);
}
default
{
state_entry()
{
init();
}
on_rez(integer start_param)
{
init();
}
changed(integer change)
{
// did note card change?
if(change & CHANGED_INVENTORY)
{
// initialize again
init();
}
}
touch_start(integer total_number)
{
// no note card?
if(noteCardName == "")
{
// do nothing
return;
}
// empty note card?
if(noteCardCount == 0)
{
// do nothing
return;
}
// if already past end of available note card lines
if(noteCardLine >= noteCardCount)
{
// reset to read first note card line
noteCardLine = 0;
}
// read the next line (and incriment to next line)
noteCardLineRequestId = llGetNotecardLine(noteCardName, noteCardLine++);
}
dataserver(key queryid, string data)
{
if(queryid == noteCardLineRequestId)
{
// if no more lines
if(data == EOF)
{
// note card count changed? reinitialize
init();
}
else
{
// we have something from the note card!
// display the text
llSetText(data, , 1);
}
}
// got feedback for the number of lines in the note card?
if(queryid == noteCardCountRequestId)
{
// save number of lines
noteCardCount = (integer)data;
// no lines?
if(noteCardCount == 0)
{
// notify owner of problem
llOwnerSay("Hey, this note card is empty");
}
else
{
// request first line
noteCardLineRequestId = llGetNotecardLine(noteCardName, noteCardLine++);
}
}
}
}
Posted by Second Life Resident Dedric Mauriac - Visit Nowhereville
–––